package com.bitin.common.data.auditing;

import com.bitin.common.data.model.Auditor;
import org.springframework.data.domain.AuditorAware;

import java.util.Optional;

/**
 * @Author: Mr.Lu
 * @Datetime 2024/8/13 21:38
 */
public class AuditorAwareImpl implements AuditorAware<String> {

    private Optional<Auditor> auditor = Optional.empty();

    /**
     * @param auditor the auditor to set
     */
    public void setAuditor(Auditor auditor) {
        this.auditor = Optional.ofNullable(auditor);
    }

    @Override
    public Optional<String> getCurrentAuditor() {
        return auditor.map(Auditor::getId);
    }
}
